package com.ruoyi.fs.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.fs.mapper.FsLawyerMapper;
import com.ruoyi.fs.domain.FsLawyer;
import com.ruoyi.fs.service.IFsLawyerService;

/**
 * 律师信息Service业务层处理
 * 
 * @author hero
 * @date 2024-09-01
 */
@Service
public class FsLawyerServiceImpl implements IFsLawyerService 
{
    @Autowired
    private FsLawyerMapper fsLawyerMapper;

    /**
     * 查询律师信息
     * 
     * @param id 律师信息主键
     * @return 律师信息
     */
    @Override
    public FsLawyer selectFsLawyerById(Long id)
    {
        return fsLawyerMapper.selectFsLawyerById(id);
    }

    /**
     * 查询律师信息
     *
     * @param userId 律师信息主键
     * @return 律师信息
     */
    @Override
    public FsLawyer selectFsLawyerByUserId(Long userId)
    {
        FsLawyer query = new FsLawyer();
        query.setUserId(userId);
        List<FsLawyer> list = fsLawyerMapper.selectFsLawyerList(query);
        if (list.isEmpty()) {
            return null;
        } else {
            return list.get(0);
        }
    }


    /**
     * 查询律师信息
     *
     * @param bh 律师信息主键
     * @return 律师信息
     */
    public FsLawyer selectFsLawyerByBh(String bh){
        FsLawyer query = new FsLawyer();
        query.setBh(bh);
        List<FsLawyer> list = fsLawyerMapper.selectFsLawyerList(query);
        if (list.isEmpty()) {
            return null;
        } else {
            return list.get(0);
        }
    }
    /**
     * 查询律师信息
     *
     * @param zjhm 律师信息主键
     * @return 律师信息
     */
    public FsLawyer selectFsLawyerByZjhm(String zjhm){
        FsLawyer query = new FsLawyer();
        query.setSfzh(zjhm);
        List<FsLawyer> list = fsLawyerMapper.selectFsLawyerList(query);
        if (list.isEmpty()) {
            return null;
        } else {
            return list.get(0);
        }
    }

    /**
     * 查询律师信息列表
     * 
     * @param fsLawyer 律师信息
     * @return 律师信息
     */
    @Override
    public List<FsLawyer> selectFsLawyerList(FsLawyer fsLawyer)
    {
        return fsLawyerMapper.selectFsLawyerList(fsLawyer);
    }

    /**
     * 新增律师信息
     * 
     * @param fsLawyer 律师信息
     * @return 结果
     */
    @Override
    public int insertFsLawyer(FsLawyer fsLawyer)
    {
        fsLawyer.setCreateTime(DateUtils.getNowDate());
        return fsLawyerMapper.insertFsLawyer(fsLawyer);
    }

    /**
     * 修改律师信息
     * 
     * @param fsLawyer 律师信息
     * @return 结果
     */
    @Override
    public int updateFsLawyer(FsLawyer fsLawyer)
    {
        fsLawyer.setUpdateTime(DateUtils.getNowDate());
        return fsLawyerMapper.updateFsLawyer(fsLawyer);
    }

    /**
     * 批量删除律师信息
     * 
     * @param ids 需要删除的律师信息主键
     * @return 结果
     */
    @Override
    public int deleteFsLawyerByIds(Long[] ids)
    {
        return fsLawyerMapper.deleteFsLawyerByIds(ids);
    }

    /**
     * 删除律师信息信息
     * 
     * @param id 律师信息主键
     * @return 结果
     */
    @Override
    public int deleteFsLawyerById(Long id)
    {
        return fsLawyerMapper.deleteFsLawyerById(id);
    }
}
